<template>
	<view class="content">
		<view class="panel_box">
			<view class="seach_box">
				<view class="search">
					<view class="icon_search"><uni-icons type="search" color="#333333" :size="icons[30]" /></view>
					<view class="search_input">
						<input v-model="params.seach_info" @input="seachInfo" placeholder-style="font-size:26rpx" placeholder="关键字搜索" value="" />
					</view>
					<view class="icon_search"></view>
				</view>
				<view class="seach_info" @click="seachInfo">搜索</view>
			</view>
		</view>
		
		
		<view class="panel_box" v-if="showType==0">
			<view class="box_title">
				<view class="title_left">分类</view>
			</view>
		</view>
		
		<view class="panel_box" v-if="showType==0">

			<view class="scroll_nav" style="margin-bottom: 0rpx;">
				<scroll-view class="scroll-view_H" scroll-x="true" scroll-left="0">
					<view class="scroll-view-item_H" v-for="(item,index) in orderStatus" :key="index" v-if="member.opt['order_check']||item.key!='2'" :class="tabSubItem == item.key ? 'cur' : ''" :data-id="item.key"  @click="selectTab">
						<view class="scroll-view-title">{{item.val}}</view>
					</view>
				</scroll-view>
			</view>
			<view class="scroll_nav" style="margin-top: 0rpx;">
				<scroll-view class="scroll-view_H" scroll-x="true" scroll-left="0">
					<view class="scroll-view-item_H" v-for="(item,index) in orderType" :key="index"  :class="tabOrderType == item.key ? 'cur' : ''"  :data-id="item.key" @click="selectOrderType">
						<view class="scroll-view-title">{{item.val}}</view>
					</view>
				</scroll-view>
			</view>
		</view>
		
		<view class="panel_box">
			<view class="box_title">
				<view class="title_left">列表</view>
			</view>
		</view>
		
		<view class="panel_box" v-for="(item,index) in dataList" :key="index" >
			<view class="panel_item">
				
				<uni-collapse>
					<uni-collapse-item :title="'编号：'+item.order_num" :open="listOpen">
						<!--<view class="order_num">
							<text>编号：{{item.saler_name}}</text> 
						</view>-->
						
						<view class="box_content" style="overflow: hidden; ">
							<view class="order_list" style="border-bottom: 1rpx  dashed #9a9a9a;">
								<view class="list_item">
									
									
									
									<view class="item_top">
										<view class="top_left">{{item.customer_name}}<text v-if="item.is_ret" style="color: #f73131;">(退回)</text></view>
										<view class="top_left item_type" v-if="item.order_type">{{item.order_type}}</view>
										<view class="top_right" v-if="!item.cerp_status">{{orderStatusMap[item.status]}}</view>
										<view class="top_right" v-if="item.cerp_status">{{cerpStatus[item.cerp_status]}}</view>
									</view>
									
									<view class="order_list_item" v-for="(val,k) in item.order_items" :key="k">
										<view v-if="item.status==1" style="margin-top: -20rpx; left: 20rpx;text-align: right; position: absolute;">
											<uni-icons type="clear" color="#3a3a3a" :size="icons[40]" @click="()=>{showDel=true;opt={'name':'delProduct','id':val.id}}"></uni-icons>
										</view>
										<view class="product_box">
											<view class="product_item">
												<view class="product_img"><image mode="aspectFill" :src="host+'/static/banner/banner1.png'"></image></view>
												<view class="product_info">
													<view class="product_title">{{val.inv_name}}</view>
													<view class="product_type">{{val.pcategory}}</view>
													<view class="product_type" style="font-size: 28rpx;" v-if="val.inv_code" >存货编码:{{val.inv_code}}</view>
												</view>
												<view class="product_num">
													<view class="num_item"><view class="num_unit">卷</view><view class="num_txt">{{val.roll_num}}</view> </view>
													<view class="num_item"><view class="num_unit">箱</view><view class="num_txt">{{val.box_num}}</view> </view>
													<view class="num_item" v-if="val.cr_weight"><view class="num_unit">KG</view><view class="num_txt">{{val.cr_weight}}</view> </view>
													<view class="num_item"><view class="num_txt">{{val.total_price}}</view><view class="num_unit">¥</view> </view>
													<view class="num_item"><view class="num_unit">(卷/箱)</view><view class="num_txt">{{val.piece_num}}</view></view>
												</view>
											</view>
										</view>
										
										
										<view class="product_desc">
											<view v-if="item.pro_type==1">
												<text>详细参数：</text>
												<text>长：{{val.pro_length}}M，</text>
												<text>宽：{{val.pro_width}}MM，</text>
												<text>平方：{{val.pro_square}}㎡</text>
											</view>
											
											<view v-if="item.pro_type!=1">
												<text>详细参数：</text>
												<text>{{val.inv_std}}</text>
											</view>
											
											<view>
												<text v-if="val.roll_weight">每卷重量：{{val.roll_weight}}kg/卷，</text>
											</view>
											
											<view>
												<text v-if="val.pro_thick">厚度：{{val.pro_thick}}，</text>
												<text v-if="val.pro_color">颜色：{{val.pro_color}}，</text>	
												<text v-if="val.pro_glue">胶水：{{val.pro_glue}}</text>									
											</view>
											
											<view>
												<text v-if="val.pro_bz">包装方式：{{val.pro_bz}}</text>		
												<text v-if="val.print_txt">印刷内容：{{val.print_txt}}</text>									
											</view>
											<view>
												<text v-if="val.mark">备注：{{val.mark}}</text>									
											</view>
											<view v-if="tabSubItem==2">
												<text v-if="val.cost_price">成本单价：¥{{val.cost_price}}，</text>
												<text v-if="val.cost_total">成本总价：¥{{val.cost_total}}</text>
											</view>
											
											<view >
												<text v-if="val.cbkg_price">公斤价：¥{{val.cbkg_price}}，</text>
												<text v-if="val.cbpf_price">平方价：¥{{val.cbpf_price}}，</text>
												<text v-if="val.pro_zg">纸管：{{val.pro_zg}}，</text>
												
												
											</view>
											
										</view>
										
										
										<view class="product_img"  v-if="val.print_imgs_list">
											<view class="product_img_title">设计稿图片：</view>
											<view class="product_desc_item">
												<view style="overflow: hidden;margin-top: 20rpx"><u-upload :fileList="val.print_imgs_list" multiple :maxCount="val.print_imgs_list.length"></u-upload></view>
											</view>
										</view>		
										
										
										<view class="item_opt"  v-if="item.status==1">
											
											<view class="button_box" >
												<view class="item_button" @click="editOrder(val.id,val.product_id)">
													<uni-icons type="compose" color="#9a9a9a" :size="icons[30]" />
													<text>编辑</text>
												</view>				
											</view>
											<view class="button_box" >
												<view class="item_button" @click="()=>{showDel=true;opt={'name':'delProduct','id':val.id}}">
													<uni-icons type="trash-filled" color="#9a9a9a" :size="icons[30]" />
													<text>删除</text>
												</view>				
											</view>
											
										</view>
									</view>

								</view>

							</view>
						</view>
						
						<view class="product_total" style="color: #f73131;" v-if="item.ret_msg">
							退回原因：{{item.ret_msg}}
						</view>
						
						<view class="product_total">
							
							<text v-if="tabSubItem==2">成本总价：¥{{item.cost_total}}，</text>
		
							<text> 总价：¥{{item.total_price}}</text>
							
							<text style="color: #f73131; padding-left: 20rpx;"> ({{payStatus[item.is_pay]}})</text>
							
						</view>
						
						<view class="product_total" >
							<text> 已付金额：¥{{item.pay_money?item.pay_money:0.00}}</text>
						</view>
						
						<view class="product_total" >
							<text v-if="item.material_nums">材料数量：{{item.material_nums}}，</text>
							<text v-if="item.material_cost">材料价格：¥{{item.material_cost}}</text>
						</view>
						<view class="product_total" v-if="item.category_type==0" ><text> u8订单状态：{{item.u8_status.cBillStatus}},{{item.u8_status.cDisSign}}</text></view>
						<view class="product_total" v-if="item.u8_rk_time">
							<view style="overflow: hidden;padding: 10rpx 0rpx;"><text v-if="item.u8_rk_time">入库时间：{{item.u8_rk_time}}</text></view>
							<view style="overflow: hidden;padding: 10rpx 0rpx;"><text v-if="item.u8_ck_time">出库时间：{{item.u8_ck_time}}</text></view>
						</view>
						
						<view class="product_total">
							<text style="margin-right: 20rpx;" v-if="item.product_area">生产地：{{item.product_area}}</text> 
							<text style="margin-right: 20rpx;">制单人：{{item.user_name}}</text> 
							<text >业务员：{{item.saler_name}}</text> 
						</view>
						
						<view class="product_total" v-if="item.worker">
							<text>贴膜师傅：{{item.worker}}</text> 
						</view>
						<view class="product_total" v-if="item.material_time" >
							<text> 材料录入时间：{{item.material_time}}</text>
						</view>
						
						<view class="product_total" v-if="item.mark">
							<text >备注：{{item.mark}}</text> 
						</view>
						<view class="product_total">
							<text> 下单日期：{{item.create_date}}</text>
						</view>
						
						<view class="product_opt" style="overflow: hidden;height: 200rpx;">
							
							<view class="button_box"  v-if="tabSubItem!=2&&(item.pay_mode!=2||(item.pay_mode==2&&[2,6].indexOf(item.is_pay)==-1))">
								<button type="default" size="mini" @click="()=>{showDel=true;opt={'name':'delOrder','id':item.id}}">删除</button>				
							</view>
							
							<view>
								<view class="button_box" v-if="item.category_type==1&&item.is_pay==2&&item.material_cost==0">
									<button type="default" size="mini" @click="submitMaterial(index)">材料录入</button>				
								</view>	
							</view>
							
							<view>
								<view class="button_box" v-if="item.is_deliver==1&&item.pro_type==1&&item.status>4&&item.cerp_sync_need==0">
									<button type="default" size="mini" @click="submitDeliver(item.id)">发货</button>				
								</view>	
							</view>
							
							<view v-if="item.status==1">
								<view class="button_box">
									<button type="default" size="mini" @click="submitOrder(index)">提交</button>				
								</view>	
							</view>
							
							<view v-if="optInfo.qr_img&&item.status>2&&[1,6].indexOf(item.is_pay)!=-1">
								<view class="button_box">
									<!--<button type="default" size="mini" @click="getQrcodeBox(item.id)">{{optInfo.qr_img["button_txt"]}}</button>-->	
									<button type="default" size="mini" @click="paymentOpt(item.id,item.total_price)">{{optInfo.qr_img["button_txt"]}}</button>
								</view>	
							</view>
							
							<view v-if="optInfo.qr_img&&item.status>2&&item.is_pay==4">
								<view class="button_box">
									<button type="default" size="mini" @click="refundQuery(item.id)">{{optInfo.qr_img["refund_query"]}}</button>				
								</view>	
							</view>
							
							<view v-if="optInfo.qr_img">
								<view class="button_box">
									<button type="default" size="mini" @click="payAgain(item.id)">{{optInfo.qr_img["pay_again"]}}</button>				
								</view>				
							</view>
							
							<view v-if="item.cerp_synced==2">
								<view class="button_box">
									<button type="default" size="mini" @click="submitOrder(index)">重新提交</button>				
								</view>				
							</view>
							
							<view v-if="item.cerp_delivery_state==2">
								<view class="button_box">
									<button type="default" size="mini" @click="deliverInfo(item.id)">发货</button>				
								</view>				
							</view>
							
							
							<view v-if="tabSubItem==2">
								<view class="button_box" >
									<button type="default" size="mini" @click="rebackOrder(item.id)">退回</button>				
								</view>
								<view class="button_box" >
									<button type="default" size="mini" @click="auditOrder(item.id)">审核</button>				
								</view>
							</view>
						</view>
					</uni-collapse-item>
				</uni-collapse>
				
			</view>
		</view>
		
		<view v-if="dataList.length==0" class="empty_box">
			暂无数据
		</view>
		<view style="overflow: hidden;height: 50rpx;"></view>
		
		
		<u-modal :show="rebackShow" confirmColor="#910a15"  title="请填写退回原因" showCancelButton :closeOnClickOverlay="true" @confirm="confirmReback" @cancel="()=>{this.rebackShow=false}" >
			<view class="slot-content" style="width: 100%; overflow: hidden;">
				<u--textarea v-model="rebackInfo.msg" placeholder="请输入退回原因" count ></u--textarea>
			</view>
		</u-modal>
		
		
		<u-modal content="是否确认删除？" :show="showDel" showCancelButton closeOnClickOverlay @confirm="confirmDel" @cancel="()=>{this.showDel=false}"  ></u-modal>
		
		<u-modal content="是否确认退款？" :show="showRefund" showCancelButton closeOnClickOverlay @confirm="confirmRefund" @cancel="()=>{this.showRefund=false}"  ></u-modal>
		
		<u-modal title="是否确认发货？" :show="showDeliver" showCancelButton closeOnClickOverlay @confirm="confirmDeliver" @cancel="()=>{this.showDeliver=false}"  >
			<view class="slot-content">
				<view class="form_box" >
					<uni-forms ref="form" :rules="rules" >
						<uni-forms-item   label="发货仓库:" name="product_area">
							<view class="form_item_input" style="width: 300rpx;">
								<picker @change="deliverChange"  :value="warehouseIndex" :range="warehouseList" :range-key="'cWhName'">
									<view style="padding-left: 20rpx;line-height: 60rpx;" class="uni-input">{{warehouseList[warehouseIndex].cWhName}}</view>
								</picker>
							</view>
						
						</uni-forms-item>
					</uni-forms>
					
				
				</view>
			</view>
		</u-modal>
		
		<paymentQrcode :show.sync="qrShow" :orderId.sync="curOrderId" :title.sync="qrBoxTitle" :tabSubItem.sync="tabSubItem" :reload.sync="reload" :payData.sync="payInfo"></paymentQrcode>
		
		<refundQuery :show.sync="refundShow" :orderId.sync="retOrderId" title="详情信息" ></refundQuery>

		<payMoney :show.sync="payShow" :price.sync="pMoney" :payData.sync="payInfo" title="付款信息" ></payMoney>
		
		<payCode :show.sync="codeShow"  :payData.sync="payInfo" title="付款码信息" ></payCode>
		
		<materialInfo :show.sync="showMaterial"  :optData.sync="materialInfo" title="材料信息" ></materialInfo>
		
		<payImg :show.sync="imgShow"  :orderId.sync="curOrderId" :imgs.sync="payImgs" :payData.sync="payInfo" title="上传付款记录" ></payImg>
		
		<orderInfo :show.sync="orderOptShow"  :optData.sync="orderOpt" title="详细信息" ></orderInfo>
		
		<deliverListPopup :show.sync="deliverShow"  :optData.sync="deliverOpt" title="发货信息" ></deliverListPopup>
		
		<u-modal content="确定要再次购买么？" :show="payAgainShow" showCancelButton closeOnClickOverlay @confirm="payAgainConfirm" @cancel="()=>{this.payAgainShow=false}"  ></u-modal>
		
	</view>
</template>


<script>
	import paymentQrcode from '@/packagePages/pages/order/components/payment-qrcode/payment-qrcode.vue'
	import refundQuery from '@/packagePages/pages/order/components/refund-query/refund-query.vue'
	import payMoney from '@/packagePages/pages/order/components/pay-money/pay-money.vue'
	import payCode from '@/packagePages/pages/order/components/pay-code/pay-code.vue'
	import materialInfo from '@/packagePages/pages/order/components/material-info/material-info.vue'
	import payImg from '@/packagePages/pages/order/components/pay-img/pay-img.vue'
	
	import orderInfo from '@/packagePages/pages/order/components/order-info/order-info.vue'
	import deliverListPopup from '@/packagePages/pages/order/components/deliver-list-popup/deliver-list-popup.vue'
	import parentPage from '@/common/parent-page.js';
	import {index} from './index.js';
	export default {mixins: [parentPage,index],components: {'materialInfo': materialInfo,'payImg': payImg,'paymentQrcode': paymentQrcode,'refundQuery': refundQuery,'payMoney': payMoney,'payCode': payCode,'orderInfo': orderInfo,'deliverListPopup': deliverListPopup}}
</script>



<style>
	@import './index.css';
</style>
